
**** Table H-15 
use "$datadir\ewallet\early_adopters.dta", clear 

	**** Create panel  for active merchants
	egen time_id = group(time)
	replace state = "ANDAMAN AND NICOBAR" if state == "ANDAMAN AND NICOBAR ISLANDS"
	merge m:1 state district using "$datadir\districts\districts_crosswalk.dta"
	drop if _m == 1
	bys state_census2001 district_census2001: egen maxmerge = max(_m)
	drop if maxmerge == 3 & _m != 3
	replace amount  = 0 if maxmerge == 2
	replace transaction  = 0 if maxmerge == 2
	drop _m maxmerge
	replace state = state_census2001
	replace district = district_census2001
	drop state_census2011 district_census2011 state_census2001 district_census2001
	replace district = trim(district)
	replace state = trim(state)
	duplicates drop
	drop if time == .
	
	
	preserve
		use "$datadir\ewallet\maindata.dta", clear
		bys time: egen exposure_5 = xtile(invshare_sd), nq(3)
		keep time exposure_5 invshare_sd own_sci lang_conc wtg_sci_exposure district state district_id  state_id large_metro_area threshold_merchants_1000 NE_states_1 share_rural logpop_T l_preshockdeposit201604 s_status_atm s_status_commercialbank
		save "$datadir\temp.dta", replace
	restore
	
	merge m:1 district state time using "$datadir\temp.dta" 
	keep if _m == 3
	drop _m
	erase "$datadir\temp.dta" 
	
	preserve
		keep district_id own_sci lang_conc
		duplicates drop
		egen high_sci = xtile(own_sci), nq(2)
		replace high_sci = high_sci - 1
		
		egen high_lang_conc = xtile(lang_conc), nq(2)
		replace high_lang_conc = high_lang_conc - 1
		keep district_id high_sci high_lang_conc own_sci lang_conc
		 
		save "$datadir\temp.dta", replace
	restore
	
	merge m:1 district_id using "$datadir\temp.dta" 
	keep if _m == 3
	drop _m
	erase "$datadir\temp.dta" 
	
	bys district_id : egen nfirms = nvals(merchant_id)
	

	g logamount = log(1+amount)
	g logtrans = log(1+trans)
		
	forval i=1/14{
		g timeid`i'Xexposure = (time_id == `i')*invshare_sd
		forval j=0/1{
			g timeid`i'XexposureXhigh_sci`j' = (time_id == `i')*invshare_sd*(high_sci == `j')
		}
		forval j=0/1{
			g timeid`i'XexposureXhigh_lang`j' = (time_id == `i')*invshare_sd*(high_lang_conc == `j')
		}
		
	}
	replace timeid6Xexposure = 0
	replace timeid6XexposureXhigh_sci0 = 0
	replace timeid6XexposureXhigh_sci1 = 0
	replace timeid6XexposureXhigh_lang0 = 0
	replace timeid6XexposureXhigh_lang1 = 0
	
	g post = (time >= 201611)
	g short_run = (time >= 201611 & time <= 201701)
	g longrun = (time > 201701)
	g postXexposure = post*invshare_sd
	g SRXexposure = short_run*invshare_sd
	g LRXexposure = longrun*invshare_sd
	
	cls
	reghdfe logamount postXexposure if $filters, a(i.merchant_id i.time_id $controls#i.time_id) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_15", tex(frag) ctitle(" amount ") dec(3) bracket label addtext(Firm f.e. , $\checkmark$ , Month f.e. , $\checkmark$ , District Controls $\times$ Month f.e., $\checkmark$) nocons nonotes stats(coef se)  replace
	reghdfe logamount SRXexposure LRXexposure if $filters, a(i.merchant_id i.time_id $controls#i.time_id) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_15", tex(frag) ctitle(" amount ") dec(3) bracket label addtext(Firm f.e. , $\checkmark$ , Month f.e. , $\checkmark$ , District Controls $\times$ Month f.e., $\checkmark$) nocons nonotes stats(coef se)  append
	reghdfe logamount postXexposure c.postXexposure#c.high_sci c.post#c.high_sci  if $filters, a(i.merchant_id i.time_id $controls#i.time_id ) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_15", tex(frag) ctitle(" amount ") dec(3) bracket label addtext(Firm f.e. , $\checkmark$ , Month f.e. , $\checkmark$ , District Controls $\times$ Month f.e., $\checkmark$) nocons nonotes stats(coef se)  append
	reghdfe logamount SRXexposure LRXexposure c.SRXexposure#c.high_sci c.LRXexposure#c.high_sci c.post#c.high_sci  if $filters, a(i.merchant_id i.time_id $controls#i.time_id ) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_15", tex(frag) ctitle(" amount ") dec(3) bracket label addtext(Firm f.e. , $\checkmark$ , Month f.e. , $\checkmark$ , District Controls $\times$ Month f.e., $\checkmark$) nocons nonotes stats(coef se)  append
	reghdfe logamount postXexposure c.postXexposure#c.high_lang_conc c.post#c.high_lang_conc  if $filters, a(i.merchant_id i.time_id $controls#i.time_id ) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_15", tex(frag) ctitle(" amount ") dec(3) bracket label addtext(District f.e. , $\checkmark$ , Month f.e. , $\checkmark$ , District Controls $\times$ Month f.e., $\checkmark$) nocons nonotes stats(coef se)  append
	reghdfe logamount SRXexposure LRXexposure c.SRXexposure#c.high_lang_conc c.LRXexposure#c.high_lang_conc c.post#c.high_lang_conc  if $filters, a(i.merchant_id i.time_id $controls#i.time_id ) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_15", tex(frag) ctitle(" amount ") dec(3) bracket label addtext(Firm f.e. , $\checkmark$ , Month f.e. , $\checkmark$ , District Controls $\times$ Month f.e., $\checkmark$) nocons nonotes stats(coef se)  append
	